package by.alex.dzeshko.lastfmsimple.bo;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import by.alex.dzeshko.lastfmsimple.bo.common.JSONModel;

public class YoutubeSearchModel extends JSONModel {

	private static final String $T = "$t";
	private static final String YT$VIDEOID = "yt$videoid";
	private static final String MEDIA$GROUP = "media$group";
	private static final String ENTRY = "entry";
	private static final String FEED = "feed";

	public YoutubeSearchModel() {
		super();
	}

	public YoutubeSearchModel(JSONObject jsonObject) {
		super(jsonObject);
	}

	public YoutubeSearchModel(String jsonString) throws JSONException {
		super(jsonString);
	}
	//feed - entry[] - item{ - media$group - yt$videoid - $t }

	public String getVideoId() throws JSONException{
		JSONArray entries = jo.getJSONObject(FEED).getJSONArray(ENTRY);
		JSONObject item = entries.getJSONObject(0);
		JSONObject media = item.getJSONObject(MEDIA$GROUP);
		return media.getJSONObject(YT$VIDEOID).getString($T);
	}
}
